Clean Python by Sunil Kapil
Author:Sunil Kapil
Language: eng
Format: epub, azw3
ISBN: 9781484248782
Publisher: Apress
As you know, metaclasses create classes. Just like you can create classes in order to create objects, in the same way Python metaclasses create these objects. In other words, metaclasses are classes’ classes. As this section is not about how metaclasses work, I will focus on when you should consider using metaclasses.
Most of the time you won’t need metaclasses in your code. The main use case of a metaclass is to create an API or library or add some complex feature. Whenever you want to hide a lot of detail and make it easier for the client to use your API/library, metaclasses can be really helpful to do that.
Take, for example, Django ORM, which heavily uses metaclasses to make its ORM API easy to use and understand. Django makes this possible by using metaclasses, and you write the Django ORM as shown in Listing 4-5.class User(models.Model):
name = models.CharField(max_length=30)
age = models.IntegerField()
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Coding Theory | Localization |
Logic | Object-Oriented Design |
Performance Optimization | Quality Control |
Reengineering | Robohelp |
Software Development | Software Reuse |
Structured Design | Testing |
Tools | UML |
Deep Learning with Python by François Chollet(11981)
Hello! Python by Anthony Briggs(9429)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9395)
The Mikado Method by Ola Ellnestam Daniel Brolund(9357)
Dependency Injection in .NET by Mark Seemann(8902)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(7901)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7422)
Grails in Action by Glen Smith Peter Ledbrook(7336)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7165)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6013)
Kotlin in Action by Dmitry Jemerov(4692)
Practical Vim (for Kathryn Amaral) by Drew Neil(3753)
Cracking the GRE Premium Edition with 6 Practice Tests, 2015 (Graduate School Test Preparation) by Princeton Review(3630)
Linux Device Driver Development Cookbook by Rodolfo Giometti(3542)
Learn Windows PowerShell in a Month of Lunches by Don Jones(3283)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(3273)
Microservices with Go by Alexander Shuiskov(3055)
Practical Design Patterns for Java Developers by Miroslav Wengner(2971)
Test Automation Engineering Handbook by Manikandan Sambamurthy(2915)